#include<iostream>
#include<vector>

using namespace std;

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        auto it = nums.begin();
        while (it != nums.end() && (it + 1) != nums.end())
        {
            if (*it == *(it + 1))
            {
                nums.erase(it + 1);
            }
            else
            {
                it++;
            }
        }
        return nums.size();
    }
};